{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Check Phrasal paper to see how they split the corpus\n",
    "# they only use en-fr from autodesk, not en-de"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import codecs\n",
    "from collections import Counter, OrderedDict, defaultdict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# EN-DE\n",
    "# train_source_file = '/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/autodesk.train.en.bpe'\n",
    "# train_target_file = '/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/autodesk.train.de.bpe'\n",
    "\n",
    "# EN-FR\n",
    "# train_source_file = '/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/en-fr/autodesk.train.en.bpe'\n",
    "# train_target_file = '/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/en-fr/autodesk.train.fr.bpe'\n",
    "\n",
    "# EN-PT\n",
    "train_source_file = '/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/en-pt/autodesk.train.en.bpe'\n",
    "train_target_file = '/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/en-pt/autodesk.train.pt.bpe'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_segments_from_file(filename, max_segs=50000):\n",
    "    with codecs.open(filename, encoding='utf8') as inp:\n",
    "        for i, l in enumerate(inp):\n",
    "            if i < max_segs:\n",
    "                yield l.strip().split()\n",
    "            else:\n",
    "                raise StopIteration\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def all_ngrams_in_segment(segment, min_ngram, max_ngram):\n",
    "    # note we return the set to only count each ngram once per segment\n",
    "    return list(set([u' '.join(ngram) for factor in range(min_ngram, max_ngram+1) \n",
    "                     for ngram in [segment[i:i+factor] for i in range(len(segment)-factor+1)]]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def count_ngrams_in_corpus(segments, min_ngram, max_ngram):\n",
    "    ngram_counts = Counter()\n",
    "    ngram_lines = []\n",
    "    for segment in segments:\n",
    "        ngrams = all_ngrams_in_segment(segment, min_ngram, max_ngram)\n",
    "        ngram_counts.update(ngrams)\n",
    "        ngram_lines.append(ngrams)\n",
    "    return ngram_counts, ngram_lines"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Size of corpus: 100000.0\n"
     ]
    }
   ],
   "source": [
    "# the number of lines in the dataset\n",
    "num_segments = 100000.\n",
    "\n",
    "# num_segments = 107478.\n",
    "print('Size of corpus: {}'.format(num_segments))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "MIN_NGRAM = 1\n",
    "MAX_NGRAM = 4\n",
    "\n",
    "train_source = get_segments_from_file(train_source_file, max_segs=num_segments)\n",
    "train_target = get_segments_from_file(train_target_file, max_segs=num_segments)\n",
    "\n",
    "source_ngrams, source_line_ngrams = count_ngrams_in_corpus(train_source, min_ngram=MIN_NGRAM, max_ngram=MAX_NGRAM)\n",
    "target_ngrams, target_line_ngrams = count_ngrams_in_corpus(train_target, min_ngram=MIN_NGRAM, max_ngram=MAX_NGRAM)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ngrams in source: 1515849\n"
     ]
    }
   ],
   "source": [
    "print('Ngrams in source: {}'.format(len(source_ngrams)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "max_occs = 500\n",
    "min_occs = 5\n",
    "def prune_high_low_freq(counter):\n",
    "    for ngram, count in counter.items():\n",
    "        if count > max_occs or count < min_occs:\n",
    "            del counter[ngram]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "prune_high_low_freq(source_ngrams)\n",
    "prune_high_low_freq(target_ngrams)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ngrams in source: 99308\n"
     ]
    }
   ],
   "source": [
    "print('Ngrams in source: {}'.format(len(source_ngrams)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "src_priors = OrderedDict((k, v / float(num_segments)) for k,v in source_ngrams.most_common())\n",
    "trg_priors = OrderedDict((k, v / float(num_segments)) for k,v in target_ngrams.most_common())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "123365"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(trg_priors)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "99308"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(src_priors)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from collections import defaultdict, Counter\n",
    "\n",
    "chunk_map = defaultdict(Counter)\n",
    "\n",
    "for src_chunks, trg_chunks in zip(source_line_ngrams, target_line_ngrams):\n",
    "    for src_chunk in set(src_chunks):\n",
    "        if src_chunk in source_ngrams:\n",
    "            chunk_map[src_chunk].update(list(set([chunk for chunk in trg_chunks if chunk in target_ngrams])))\n",
    "\n",
    "del source_line_ngrams\n",
    "del target_line_ngrams"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "processed 10000\n",
      "processed 20000\n",
      "processed 30000\n",
      "processed 40000\n",
      "processed 50000\n",
      "processed 60000\n",
      "processed 70000\n",
      "processed 80000\n",
      "processed 90000\n"
     ]
    }
   ],
   "source": [
    "src_posteriors = {}\n",
    "num_processed = 0\n",
    "for src_chunk, trg_chunk_counter in chunk_map.items():\n",
    "    total_occs = float(source_ngrams[src_chunk])\n",
    "    posteriors = OrderedDict([(k, v / total_occs) for k, v in trg_chunk_counter.most_common()])\n",
    "    del chunk_map[src_chunk]\n",
    "    src_posteriors[src_chunk] = posteriors\n",
    "    num_processed += 1\n",
    "    if num_processed % 10000 == 0:\n",
    "        print('processed {}'.format(num_processed))\n",
    "del chunk_map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy\n",
    "\n",
    "def normalized_pmi(p_x, p_y, p_y_given_x):\n",
    "    joint = p_x * p_y_given_x\n",
    "    normalize = -numpy.log(joint)\n",
    "    return numpy.log(p_y_given_x / p_y) / normalize"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "processed 10000\n",
      "processed 20000\n",
      "processed 30000\n",
      "processed 40000\n",
      "processed 50000\n",
      "processed 60000\n",
      "processed 70000\n",
      "processed 80000\n",
      "processed 90000\n"
     ]
    }
   ],
   "source": [
    "pmi_cands = {}\n",
    "\n",
    "num_processed = 0 \n",
    "for source_phrase, posteriors in src_posteriors.items():\n",
    "    source_prior = src_priors[source_phrase]\n",
    "    pmi_scores = []\n",
    "    for target_phrase, posterior in posteriors.items():\n",
    "        target_prior = trg_priors[target_phrase]\n",
    "        pmi_score = normalized_pmi(source_prior, target_prior, posterior)\n",
    "        pmi_scores.append((target_phrase, pmi_score))\n",
    "\n",
    "    pmi_scores = sorted(pmi_scores, key=lambda x: x[1], reverse=True)\n",
    "    pmi_cands[source_phrase] = pmi_scores\n",
    "#     del src_posteriors[source_phrase]\n",
    "    num_processed += 1\n",
    "    if num_processed % 10000 == 0:\n",
    "        print('processed {}'.format(num_processed))\n",
    "        \n",
    "# del src_posteriors\n",
    "# del trg_priors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "99308"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(pmi_cands)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14289\n"
     ]
    }
   ],
   "source": [
    "min_occs = 5\n",
    "min_score = 0.95\n",
    "min_source_len = 5\n",
    "\n",
    "good_cands = []\n",
    "for src, cands in pmi_cands.items()[:50000]:\n",
    "    if len(src) >= min_source_len and len(cands) > 0 and cands[0][1] >= min_score:\n",
    "        if source_ngrams[src] > min_occs:\n",
    "#             print(u'match: {}-->{} score {}'.format(src, cands[0][0], cands[0][1]))\n",
    "            internal_cands = [cand for cand in cands \n",
    "                              if target_ngrams[cand[0]] >  min_occs\n",
    "                              and cand[1] >= min_score]\n",
    "            # sort by length descending\n",
    "            internal_cands = sorted(internal_cands, key=lambda x: len(x[0].split()), reverse=True)\n",
    "            if len(internal_cands) > 0:\n",
    "                good_cands.append((src, cands[0]))\n",
    "            \n",
    "# TODO:\n",
    "# where the source phrase is a subset of another phrase, choose the longest one\n",
    "# choose the longest target candidate whose PMI is high enough\n",
    "print len(good_cands)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# WORKING: just print this to file and try it\n",
    "src_rules = [src for src, (trg, score) in good_cands]\n",
    "term_pair_map = OrderedDict((k,v) for k,(v,s) in good_cands)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# create terminology spotter\n",
    "from semantic_annotator.spotting import MatchSpotter\n",
    "\n",
    "term_spotter = MatchSpotter(rules=src_rules)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# import the tokenized and bpe encoded dev lines\n",
    "# prepped_dev_lines = codecs.open('/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/autodesk.dev.1000.en.bpe',\n",
    "#                                  encoding='utf8').read().strip().split('\\n')\n",
    "\n",
    "prepped_dev_lines = codecs.open('/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/en-fr/autodesk.dev.1000.en.bpe',\n",
    "                                 encoding='utf8').read().strip().split('\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "dev_term_spots = []\n",
    "for l in prepped_dev_lines:\n",
    "    spots = term_spotter.get_spots(l)\n",
    "    dev_term_spots.append(spots)\n",
    "\n",
    "dev_term_constraints = []\n",
    "for text, spots in zip(prepped_dev_lines, dev_term_spots):\n",
    "    output_constraints = []\n",
    "    if len(spots) > 0:\n",
    "        for spot in spots:\n",
    "            if spot[1] - spot[0] > 1:\n",
    "                spotted_term = text[spot[0]:spot[1]]\n",
    "                mapped_term = term_pair_map[spotted_term]\n",
    "                output_constraints.append(mapped_term.split())\n",
    "    dev_term_constraints.append(output_constraints)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1000"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(dev_term_constraints)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[[u'help@@', u'.@@', u'auto@@'],\n",
       "  [u'/', u'view', u'/', u'ICD'],\n",
       "  [u'/', u'2014', u'/'],\n",
       "  [u'?', u'cont@@', u'ext@@', u'I@@'],\n",
       "  [u'{', u'3', u'}', u'et'],\n",
       "  [u'4', u'}', u'http'],\n",
       "  [u'help@@', u'.@@', u'auto@@'],\n",
       "  [u'/', u'view', u'/', u'ICD'],\n",
       "  [u'/', u'2014', u'/'],\n",
       "  [u'?', u'cont@@', u'ext@@', u'I@@'],\n",
       "  [u'5', u'}', u'Cr\\xe9er']],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [[u'sk@@', u'etch@@']],\n",
       " [],\n",
       " [],\n",
       " [[u'AutoCAD', u'{', u'1', u'}'], [u'Civil', u'3D', u'{', u'2']],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [[u'file', u':', u'/'],\n",
       "  [u'clou@@', u'd@@', u'help', u'/'],\n",
       "  [u'/', u'2015', u'/'],\n",
       "  [u'CAD@@', u'-@@'],\n",
       "  [u'files', u'/', u'GU@@'],\n",
       "  [u'8@@', u'19@@', u'2-@@'],\n",
       "  [u'8@@', u'19@@', u'2-@@'],\n",
       "  [u'8@@', u'19@@', u'2-@@'],\n",
       "  [u'8@@', u'19@@', u'2-@@'],\n",
       "  [u'8@@', u'19@@', u'2-@@'],\n",
       "  [u'3', u'}', u'\\xa9', u'Copyright'],\n",
       "  [u'3', u'}', u'\\xa9', u'Copyright'],\n",
       "  [u'Inc', u'.', u'All', u'rights']],\n",
       " [],\n",
       " [[u'vous', u'enregistrez', u'un', u'fichier'],\n",
       "  [u'le', u'dans', u'un', u'dossier']],\n",
       " [],\n",
       " [[u'donn\\xe9es', u'de', u'conception']],\n",
       " [[u'ou', u'Windows'], [u'64', u'bits']],\n",
       " [],\n",
       " [[u'parent']],\n",
       " [[u'Cr\\xe9er', u'r\\xe9partition', u'>']],\n",
       " [],\n",
       " [[u'formule'], [u'.', u'{', u'2', u'}']],\n",
       " [],\n",
       " [[u'charge', u'sur@@', u'fac@@'],\n",
       "  [u'P', u'{', u'2', u'}'],\n",
       "  [u't', u'{', u'3']],\n",
       " [],\n",
       " [[u'tim@@', u'age', u'{', u'2']],\n",
       " [[u'de', u'notification', u'de', u'la'], [u'}', u'A@@', u'360', u'Drive']],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [[u'MO@@', u'DE'], [u'barre', u\"d'\", u'\\xe9tat']],\n",
       " [],\n",
       " [[u'Factory', u'Design', u'Suite', u'2015']],\n",
       " [[u'1', u'}', u'Windows', u'8']],\n",
       " [[u'd@@', u'flow', u'Communicator'],\n",
       "  [u'visu@@', u'alisations'],\n",
       "  [u',', u'la', u'correction', u's\\xe9lective'],\n",
       "  [u'Simulation', u'Mol@@']],\n",
       " [[u'iser', u'par']],\n",
       " [[u'onglet', u'G\\xe9@@', u'om\\xe9trie']],\n",
       " [[u'BI@@', u'M', u'360', u'Gl@@']],\n",
       " [[u'outils', u'suivants']],\n",
       " [[u'visualiser', u'la', u'maquette'], [u',', u'ins\\xe9rez'], [u'maquette']],\n",
       " [[u'Vault', u'2012']],\n",
       " [[u'Pour', u'les', u'administrateurs'], [u'ID', u'Autodesk']],\n",
       " [[u'passif', u','],\n",
       "  [u'R-@@', u'38'],\n",
       "  [u'passif', u',', u'Pla@@'],\n",
       "  [u'CI@@', u'BSE', u']']],\n",
       " [],\n",
       " [],\n",
       " [[u'ce', u'didacti@@']],\n",
       " [[u'F@@', u'B@@']],\n",
       " [],\n",
       " [[u'relations']],\n",
       " [],\n",
       " [[u'bo\\xeete', u'de', u'dialogue', u'Div@@']],\n",
       " [],\n",
       " [],\n",
       " [[u'-nous', u'sur'], [u'tibilit\\xe9'], [u'd\\xe9cisions']],\n",
       " [[u'Quanti@@', u'fication'],\n",
       "  [u'Quanti@@', u'fication'],\n",
       "  [u'Nav@@', u'is@@', u'works']],\n",
       " [[u'_', u'PY', u',', u'FE@@']],\n",
       " [],\n",
       " [[u'incr\\xe9@@', u'ment\\xe9e']],\n",
       " [],\n",
       " [],\n",
       " [[u'{', u'1', u'}', u'Pour']],\n",
       " [],\n",
       " [[u'Product', u'Design', u'Suite', u'.']],\n",
       " [[u':', u'00', u':'], [u'00', u':', u'01']],\n",
       " [],\n",
       " [[u'outils', u\"d'\", u'effets']],\n",
       " [[u'productivit\\xe9', u'qui', u'permettent', u'de']],\n",
       " [[u'retards']],\n",
       " [[u'AutoCAD', u'Map', u'3D', u'2015'], [u'gratuite', u'|', u'Autodesk']],\n",
       " [[u'Le', u'corps'],\n",
       "  [u'de', u'la', u'r\\xe9ponse'],\n",
       "  [u'(', u'{', u'1'],\n",
       "  [u'}', u')', u'dans'],\n",
       "  [u'imbri@@']],\n",
       " [[u'lecture', u'seule']],\n",
       " [[u'Centre', u'de', u'd\\xe9cision'], [u'simulations']],\n",
       " [[u'Microsoft', u'{', u'1'], [u'Windows', u'XP']],\n",
       " [[u'E@@', u'change', u'BI@@']],\n",
       " [],\n",
       " [[u'Remarque', u':', u'{'],\n",
       "  [u\"l'\", u'installation', u'{', u'4'],\n",
       "  [u'de', u'contr\\xf4le', u'des', u'gestionnaires']],\n",
       " [[u'm\\xe9thode', u'{', u'1']],\n",
       " [[u'Lancez', u'la', u'commande', u'Ex@@'],\n",
       "  [u'sion', u',', u'puis'],\n",
       "  [u'la', u'rain@@', u'ure']],\n",
       " [[u'bas', u'\\xe0', u'gauche', u'de'],\n",
       "  [u'et', u'coques'],\n",
       "  [u'dialogue', u'{', u'3']],\n",
       " [],\n",
       " [[u'}', u'Le', u'long'],\n",
       "  [u'Le', u'long', u'des', u'courbes'],\n",
       "  [u':', u'{', u'3']],\n",
       " [[u'reg@@', u'\\xe9n\\xe9@@']],\n",
       " [],\n",
       " [[u'Symp@@', u't@@']],\n",
       " [[u'1', u'}', u'Ajouter']],\n",
       " [[u'transformateur']],\n",
       " [[u'Bri@@', u'que', u',']],\n",
       " [],\n",
       " [],\n",
       " [[u'mental'], [u'Professional'], [u'donn\\xe9es', u'de', u'conception']],\n",
       " [[u'Intel', u'\\xae'], [u'Op@@', u'ter@@', u'on', u'\\u2122']],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [[u'dialogue', u'{', u'1']]]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dev_term_constraints[:100]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "\n",
    "# OUTPUT_DIR='/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus'\n",
    "OUTPUT_DIR='/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/en-fr'\n",
    "\n",
    "with codecs.open(os.path.join(OUTPUT_DIR, 'pmi.baseline.dev.constraints.json'), 'w', encoding='utf8') as out:\n",
    "    out.write(json.dumps(dev_term_constraints, indent=2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(u'1 } Nav@@', (u'1 } Nav@@', 0.98445032753820794)),\n",
       " (u'localized', (u'lok@@', 0.96140193746584057)),\n",
       " (u'DL@@ M', (u'DL@@ M', 0.98167267895539889)),\n",
       " (u'ei@@', (u'Decke', 0.9473565816682249)),\n",
       " (u'installed to revert Auto@@', (u'Updates den', 1.0)),\n",
       " (u'abler {', (u'AutoCAD Civil 3D Object', 0.98308124041157308)),\n",
       " (u', rendering', (u', Ren@@ dering', 0.93604792711326779)),\n",
       " (u'} As', (u'Vom {', 0.93623755231209871)),\n",
       " (u'bit ) {', (u'bit ) {', 1.0)),\n",
       " (u'Factory Design Suite 2015',\n",
       "  (u'Factory Design Suite 2015', 0.97405927122050773)),\n",
       " (u'list box', (u'Listen@@ feld auf', 0.96719814603844934)),\n",
       " (u\"a user 's\", (u'eines Benutzers', 0.91638656221226733)),\n",
       " (u'Rev@@ it LT {', (u'Rev@@ it LT {', 0.9698565171985376)),\n",
       " (u'{ 24', (u'{ 24', 1.0)),\n",
       " (u'{ 23', (u'{ 24', 1.0)),\n",
       " (u'{ 22', (u'{ 22', 1.0)),\n",
       " (u'1 } ..', (u'1 } ..', 1.0)),\n",
       " (u'marking menu', (u'Mark@@ ierungs@@ men\\xfc', 0.93841832577685758)),\n",
       " (u'in Ab@@ aqu@@', (u'in Ab@@', 0.95043650671515612)),\n",
       " (u'Tru@@ e@@', (u'Tru@@ e@@', 1.0)),\n",
       " (u'space Page', (u'chs@@ seite', 0.97156958180483732)),\n",
       " (u'128 MB', (u', Pixel', 0.99171790679106364)),\n",
       " (u'ation Method', (u'die Vari@@ ations@@ methode', 0.90182576168508366)),\n",
       " (u'PC@@ 3', (u'PC@@ 3-@@', 0.98292530365931152)),\n",
       " (u'around :', (u'Zwischen@@ l\\xf6sung :', 0.9291126460775323)),\n",
       " (u'the same directory', (u'im selben Verzeichnis', 0.96080228599128759)),\n",
       " (u'2015 Service', (u'2015 Service', 0.99442957120137254)),\n",
       " (u'system@@ re@@', (u'system@@ re@@ q@@ -@@', 0.98343581358212728)),\n",
       " (u', 3.0', (u', 3,@@', 0.96517385972461245)),\n",
       " (u'33-@@', (u'33-@@', 1.0)),\n",
       " (u'not closed during the', (u'ge\\xf6ffnet lassen , m\\xfcssen', 1.0)),\n",
       " (u'jav@@ ascript :', (u'ascript', 1.0)),\n",
       " (u'Advance Con@@', (u'Advance Con@@', 0.99113396756119621)),\n",
       " (u'or Publisher', (u'or Publisher', 0.97759212159909725)),\n",
       " (u'Invent@@ or and', (u'Invent@@ or und', 0.94583497268375083)),\n",
       " (u'8@@ A@@', (u'8@@ A@@', 1.0)),\n",
       " (u'Ad@@ sk@@ Stor@@', (u'sk@@ Stor@@ y.@@', 1.0)),\n",
       " (u'Dep@@ loyment Wizard', (u'Einrichtungs@@ assi@@', 0.97354237432762403)),\n",
       " (u'\\xae Invent@@', (u'\\xae Invent@@', 1.0)),\n",
       " (u'Constant #', (u': Benutzer@@ materi@@', 0.94757745296844076)),\n",
       " (u'| Auto@@', (u'| Auto@@ desk', 0.99558290088664125)),\n",
       " (u'Auto@@ Indu@@ str@@', (u'str@@ y@@ W@@ k@@', 1.0)),\n",
       " (u'contex@@ th@@', (u'contex@@ th@@ el@@', 1.0)),\n",
       " (u'32-@@ 000@@', (u'1-@@ 18@@ 32-@@', 1.0)),\n",
       " (u'/ wi@@ k@@', (u'/ wi@@ k@@', 0.99906169621332896)),\n",
       " (u'IM@@ 7 _', (u'IM@@ 7 _', 1.0)),\n",
       " (u'the slot', (u'des Lang@@ lo@@', 0.91092652668366958)),\n",
       " (u'a ribbon panel',\n",
       "  (u'Multifunktions@@ leist@@ en-@@ Gruppe', 0.91951331740571263)),\n",
       " (u'70@@ F@@', (u'70@@ F@@', 1.0)),\n",
       " (u'16 }', (u'16 }', 1.0)),\n",
       " (u'in ( 150', (u'( 150 mm )', 1.0)),\n",
       " (u'fix', (u'fix', 0.94234668670478972)),\n",
       " (u'sk@@ etch@@ book@@', (u'sk@@ etch@@ book@@', 1.0)),\n",
       " (u'.@@ mp@@', (u'.@@ mp@@', 0.98880967266301056)),\n",
       " (u'ch@@ pad', (u'Laun@@ ch@@', 0.96334535791079767)),\n",
       " (u'Server \\u2122', (u'Server \\u2122', 1.0)),\n",
       " (u'components , tools ,', (u'4 } enthalten sind', 0.95701851920189229)),\n",
       " (u'is the ratio of', (u'das Verh\\xe4ltnis der', 0.92578410451610949)),\n",
       " (u'in-@@ plane', (u'in der Ebene', 0.91265564548416223)),\n",
       " (u'J / (', (u'( kg \\u2022 \\xb0', 1.0)),\n",
       " (u'manipul@@ ator', (u'Manipul@@ ator', 0.93061239804498674)),\n",
       " (u'IE@@', (u'IE@@', 1.0)),\n",
       " (u'Environment dialog', (u'feld \" Umgebung \"', 0.98020468848809394)),\n",
       " (u'Sketch drop-down list', (u'down-@@ Liste Skiz@@ ze', 1.0)),\n",
       " (u'olds', (u'Reyn@@', 0.99483999257166578)),\n",
       " (u'these files', (u'diese Dateien', 0.91309751760289015)),\n",
       " (u'} Physics {', (u'} Physik', 1.0)),\n",
       " (u'( Start', (u'( Start', 0.97354237432762403)),\n",
       " (u'figur@@ ator 360', (u'Con@@ figur@@ ator', 0.99652193007362133)),\n",
       " (u'render :', (u'Ren@@ dern :', 0.93465391301286849)),\n",
       " (u'Comm@@ ands and', (u'und System@@ variablen', 0.94314388373553804)),\n",
       " (u'aspects of', (u'Aspekte der', 0.92310542299312959)),\n",
       " (u'business results', (u'Gesch\\xe4ft@@ ser@@', 0.91428366948988904)),\n",
       " (u'/ produc@@ t-@@ catalog', (u'aman@@ agement /', 1.0)),\n",
       " (u'V@@ RED', (u'V@@ RED', 0.9814294755901608)),\n",
       " (u'2 } Rev@@ it', (u'{ 2 } Rev@@', 0.98566886660105546)),\n",
       " (u'M Configuration', (u'listen@@ konfiguration', 0.95847923205119012)),\n",
       " (u'time step', (u'Zeitsch@@', 0.92297022040826049)),\n",
       " (u'list box on the', (u'Listen@@ feld auf', 0.99472187365823717)),\n",
       " (u'a Cart@@', (u'einer kart@@ esischen', 0.96346799108044034)),\n",
       " (u'AMD Op@@ ter@@', (u'AMD Op@@ ter@@', 1.0)),\n",
       " (u'( ) { 2', (u'( ) { 2', 1.0)),\n",
       " (u'Work@@ group', (u'Work@@ group', 0.98007979889109031)),\n",
       " (u'4.5', (u'4.5', 0.98852545955787818)),\n",
       " (u'need to remove the',\n",
       "  (u'Update entfernen m\\xf6chten ,', 0.98292530365931152)),\n",
       " (u'2014 with', (u'2014 mit', 0.9291474122170349)),\n",
       " (u'BP@@ A.@@', (u'BP@@ A.@@', 1.0)),\n",
       " (u'fix 1', (u'fix 1', 0.96320318591846554)),\n",
       " (u'sk /', (u'ad@@ sk /', 0.99625769476813442)),\n",
       " (u'Vault 2015', (u'Vault 2015', 0.98793473654257791)),\n",
       " (u'between 0 and', (u'zwischen 0', 0.95898950328974875)),\n",
       " (u'd@@ Name', (u'd@@ Name', 1.0)),\n",
       " (u'M@@ 360 _ HEL@@', (u'PL@@ M@@ 360 _', 1.0)),\n",
       " (u'Navi@@ er-@@ St@@', (u'er-@@ St@@ ok@@', 1.0)),\n",
       " (u\"'s Guide { 3\", (u'Handbuch { 3', 0.95145371149310742)),\n",
       " (u\"'s Guide { 2\", (u'1 } Benutzer@@ handbuch', 0.93292325987025804)),\n",
       " (u'1 } 4 Lane', (u'} 4 Lane Highway', 0.9459709430780886)),\n",
       " (u'TO@@', (u'TO@@', 0.94197398786647557)),\n",
       " (u'a rec@@ tangle', (u'ein Recht@@', 0.95858622607815114)),\n",
       " (u'1.0 and', (u'1.0 und', 0.96597324180338906))]"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "good_cands[:100]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(u'start', 500),\n",
       " (u'applied', 500),\n",
       " (u'2 } :', 499),\n",
       " (u'{ 2 } :', 499),\n",
       " (u'What', 499),\n",
       " (u'was', 498),\n",
       " (u'Update', 497),\n",
       " (u'Subscri@@ ption', 496),\n",
       " (u'R-@@', 496),\n",
       " (u'ption', 496)]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "source_ngrams.most_common(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(u'privilege on',\n",
       "  [(u'PC \\xfcber', 0.82050633570393328),\n",
       "   (u'Beta 3-@@', 0.78550731479385638),\n",
       "   (u'3-@@ Version', 0.7414137631415163),\n",
       "   (u'der Beta', 0.72567609336183414),\n",
       "   (u'lokalen PC', 0.72567609336183414),\n",
       "   (u'rechte verf\\xfcgen', 0.7008438928398889),\n",
       "   (u'2014 m\\xfcssen', 0.67335553793232839),\n",
       "   (u'Zur Installation', 0.62175132027747182),\n",
       "   (u'Ihrem lokalen', 0.60248996914707698),\n",
       "   (u'\\xfcber Administr@@', 0.57344628916161022),\n",
       "   (u'ator@@ rechte', 0.53287641885998283),\n",
       "   (u'Installation der', 0.52409071923946871),\n",
       "   (u'verf\\xfcgen .', 0.50427426518988461),\n",
       "   (u'auf Ihrem', 0.43601506618455216),\n",
       "   (u'or 2014', 0.43601506618455216),\n",
       "   (u'Administr@@ ator@@', 0.43501715672980074),\n",
       "   (u'Version von', 0.39677270819610594),\n",
       "   (u'm\\xfcssen Sie', 0.34617769699067885),\n",
       "   (u'desk Invent@@', 0.3318397320927583),\n",
       "   (u'von Auto@@', 0.28160489285413842),\n",
       "   (u'Invent@@ or', 0.23913715889811826),\n",
       "   (u'Sie auf', 0.1594822507543559),\n",
       "   (u'Auto@@ desk', 0.10663153914334215)]),\n",
       " (u'ances .',\n",
       "  [(u'widerstand oder', 0.79301798079637276),\n",
       "   (u', Kontakt@@', 0.79301798079637276),\n",
       "   (u'( Fest@@', 0.79301798079637276),\n",
       "   (u'Hindernis (', 0.79301798079637276),\n",
       "   (u'ter Str\\xf6@@', 0.79301798079637276),\n",
       "   (u'als Hindernis', 0.79301798079637276),\n",
       "   (u'widerstand verwendet', 0.79301798079637276),\n",
       "   (u'Diese Einschr\\xe4nkung', 0.73318675936435063),\n",
       "   (u'oder verteil@@', 0.73318675936435063),\n",
       "   (u'Einschr\\xe4nkung gilt', 0.73318675936435063),\n",
       "   (u'Kontakt@@ widerstand', 0.69818773845427373),\n",
       "   (u'verteil@@ ter', 0.67335553793232839),\n",
       "   (u'k\\xf6rper )', 0.63835651702225138),\n",
       "   (u'f\\xfcr Fl\\xe4@@', 0.58603596159274562),\n",
       "   (u'mungs@@ widerstand', 0.56521928538444455),\n",
       "   (u'le ,', 0.5536930950682839),\n",
       "   (u'gilt f\\xfcr', 0.45362984410426183),\n",
       "   (u'entei@@ le', 0.43269235862998395),\n",
       "   (u'ch@@ entei@@', 0.42507109913834734),\n",
       "   (u'die als', 0.42034015046539508),\n",
       "   (u'Fl\\xe4@@ ch@@', 0.37693992146786376),\n",
       "   (u'Fest@@ k\\xf6rper', 0.37219969176630729),\n",
       "   (u'Str\\xf6@@ mungs@@', 0.31436820934019499),\n",
       "   (u'verwendet werden', 0.24229724647799655),\n",
       "   (u') ,', 0.22991578286271233),\n",
       "   (u'werden .', 0.1013491471647312),\n",
       "   (u', die', 0.051106114199048071)]),\n",
       " (u'Links command',\n",
       "  [(u'Befehl Verkn\\xfcpfungen', 1.0),\n",
       "   (u'zun\\xe4chst \\xfcber', 1.0),\n",
       "   (u'Verkn\\xfcpfungen auf', 0.88033755713595552),\n",
       "   (u'leiste den', 0.82050633570393328),\n",
       "   (u'die Multifunktions@@', 0.64658352079941717),\n",
       "   (u'Sie zun\\xe4chst', 0.63835651702225138),\n",
       "   (u'Rufen Sie', 0.5646605895410961),\n",
       "   (u'auf .', 0.52236774374205408),\n",
       "   (u'Multifunktions@@ leiste', 0.48304359199397212),\n",
       "   (u'den Befehl', 0.46304981345457463),\n",
       "   (u'\\xfcber die', 0.40583185537302413)]),\n",
       " (u'you set',\n",
       "  [(u'CAD@@ Civil', 0.69067707245175713),\n",
       "   (u'Wie legen', 0.69067707245175713),\n",
       "   (u'3D fest', 0.69067707245175713),\n",
       "   (u'fest ?', 0.57101462958771276),\n",
       "   (u'geschwindigkeit der', 0.52270959847185117),\n",
       "   (u'Stra\\xdfe in', 0.52270959847185117),\n",
       "   (u'fs@@ geschwindigkeit', 0.40618634542545967),\n",
       "   (u'der Stra\\xdfe', 0.32033230864403761),\n",
       "   (u'die Entwur@@', 0.30130777029990163),\n",
       "   (u'Auto@@ CAD@@', 0.27253553143890885),\n",
       "   (u'legen Sie', 0.23290530452898262),\n",
       "   (u'in Auto@@', 0.15219607956355721),\n",
       "   (u'Civil 3D', 0.12631656934279961),\n",
       "   (u'Entwur@@ fs@@', 0.11508756984708859),\n",
       "   (u'Sie die', -0.0521877187061522)]),\n",
       " (u'in using',\n",
       "  [(u'kontos an', 0.74584130831597728),\n",
       "   (u'er@@ kontos', 0.74584130831597728),\n",
       "   (u'daten Ihres', 0.65101106597387814),\n",
       "   (u'Benutzer@@ daten', 0.6261788654519328),\n",
       "   (u'k@@ -Benutz@@', 0.60691751432153807),\n",
       "   (u'Ihres Auto@@', 0.5911798445418559),\n",
       "   (u'den Benutzer@@', 0.52443948014402764),\n",
       "   (u'Melden Sie', 0.36035212934184463),\n",
       "   (u'-Benutz@@ er@@', 0.33187726990872291),\n",
       "   (u'sich mit', 0.33046218565199897),\n",
       "   (u'mit den', 0.18782964050182133),\n",
       "   (u'Sie sich', 0.17191288724203094),\n",
       "   (u'Auto@@ des@@', 0.15009573124602363),\n",
       "   (u'an .', 0.13128712946260121),\n",
       "   (u'des@@ k@@', 0.11924742372413186)]),\n",
       " (u'use )',\n",
       "  [(u'gegen\\xfcber richtig', 0.94016877856797776),\n",
       "   (u'richtig er@@', 0.94016877856797776),\n",
       "   (u'mittelten Person@@', 0.94016877856797776),\n",
       "   (u'entypen unter', 0.88033755713595552),\n",
       "   (u'von Vertriebs@@', 0.88033755713595552),\n",
       "   (u'\\xfcberzeugenden Verkaufs@@', 0.88033755713595552),\n",
       "   (u'L\\xf6sungs@@ arbeits@@', 0.88033755713595552),\n",
       "   (u'Verkaufs@@ arguments', 0.88033755713595552),\n",
       "   (u'lagen eines', 0.88033755713595552),\n",
       "   (u'\\u201e BI@@', 0.88033755713595552),\n",
       "   (u'arguments gegen\\xfcber', 0.88033755713595552),\n",
       "   (u'eines \\xfcberzeugenden', 0.88033755713595552),\n",
       "   (u'Voraussetzung \\u201c', 0.88033755713595552),\n",
       "   (u'l\\xe4ufen (', 0.84533853622587862),\n",
       "   (u'strategien und', 0.84533853622587862),\n",
       "   (u'Vorsch@@ lagen', 0.82050633570393328),\n",
       "   (u'als Voraussetzung', 0.82050633570393328),\n",
       "   (u'\\u201c )', 0.82050633570393328),\n",
       "   (u'M als', 0.80124498457353854),\n",
       "   (u'von \\u201e', 0.80124498457353854),\n",
       "   (u'und L\\xf6sungs@@', 0.77220130458807179),\n",
       "   (u'er@@ mittelten', 0.71876695039602823),\n",
       "   (u'arbeits@@ ab@@', 0.7064147422314393),\n",
       "   (u'Vertriebs@@ strategien', 0.66584487192981201),\n",
       "   (u'Person@@ entypen', 0.66232119057909922),\n",
       "   (u'( einschlie\\xdflich', 0.5974603015059976),\n",
       "   (u'einschlie\\xdflich der', 0.56192009884544958),\n",
       "   (u'der Verwendung', 0.54094942044384464),\n",
       "   (u'ab@@ l\\xe4ufen', 0.52478965590399951),\n",
       "   (u'unter Verwendung', 0.50881837784519424),\n",
       "   (u'Verwendung von', 0.4452770425786462),\n",
       "   (u'BI@@ M', 0.42321237056194988)]),\n",
       " (u'now when',\n",
       "  [(u'Bildern wurden', 0.90516975765790086),\n",
       "   (u'geordneten T@@', 0.90516975765790086),\n",
       "   (u'Design korrigiert', 0.90516975765790086),\n",
       "   (u'mit Raster', 0.90516975765790086),\n",
       "   (u'Pfad von', 0.90516975765790086),\n",
       "   (u'wurden nun', 0.90516975765790086),\n",
       "   (u'Zeichnung zu@@', 0.84533853622587862),\n",
       "   (u'F-@@ Bildern', 0.84533853622587862),\n",
       "   (u'nun f\\xfcr', 0.76624596366346154),\n",
       "   (u'das Arbeiten', 0.75050829388377938),\n",
       "   (u'IF@@ F-@@', 0.69818773845427373),\n",
       "   (u'Name und', 0.68376792948595122),\n",
       "   (u'der Pfad', 0.68376792948595122),\n",
       "   (u'T@@ IF@@', 0.68376792948595122),\n",
       "   (u'Der Name', 0.5911798445418559),\n",
       "   (u'zu@@ geordneten', 0.58254081990387341),\n",
       "   (u'korrigiert .', 0.56923480969808882),\n",
       "   (u'Raster Design', 0.50427426518988461),\n",
       "   (u'einer Zeichnung', 0.49559572660914281),\n",
       "   (u'von einer', 0.48771057756177422),\n",
       "   (u'Arbeiten mit', 0.46601756685748191),\n",
       "   (u'und der', 0.34662195019184411),\n",
       "   (u'f\\xfcr das', 0.32102483665117065)]),\n",
       " (u'or exit',\n",
       "  [(u'gespeicherte Protokoll@@', 1.0),\n",
       "   (u'eintr\\xe4ge verloren', 1.0),\n",
       "   (u'nicht gespeicherte', 0.94016877856797776),\n",
       "   (u'Datei schlie\\xdfen', 0.94016877856797776),\n",
       "   (u'Programm beenden', 0.94016877856797776),\n",
       "   (u'schlie\\xdfen oder', 0.90516975765790086),\n",
       "   (u'gehen nicht', 0.88033755713595552),\n",
       "   (u'Protokoll@@ eintr\\xe4ge', 0.86107620600556067),\n",
       "   (u'verloren .', 0.77220130458807179),\n",
       "   (u'Sobald Sie', 0.7372022836779949),\n",
       "   (u', gehen', 0.70934106336796654),\n",
       "   (u'beenden ,', 0.69818773845427373),\n",
       "   (u'das Programm', 0.63451952060358208),\n",
       "   (u'oder das', 0.6145108210258674),\n",
       "   (u'die Datei', 0.47266070589490089),\n",
       "   (u'Sie die', 0.25713520884209062)]),\n",
       " (u'components you',\n",
       "  [(u'nicht vergleichen', 0.88033755713595552),\n",
       "   (u'Durch De@@', 0.7414137631415163),\n",
       "   (u'vergleichen m\\xf6chten', 0.68158254170949406),\n",
       "   (u'aktivieren der', 0.61753984081395041),\n",
       "   (u'der Komponenten', 0.59910450753198374),\n",
       "   (u'der Sichtbarkeit', 0.58118144997584453),\n",
       "   (u'Sichtbarkeit der', 0.57594844135392154),\n",
       "   (u'Komponenten ,', 0.55175327845731792),\n",
       "   (u'De@@ aktivieren', 0.45951926810589),\n",
       "   (u'Sie nicht', 0.44725496036279766),\n",
       "   (u'm\\xf6chten .', 0.38082295426439777),\n",
       "   (u'die Sie', 0.33646502811304618),\n",
       "   (u', die', 0.1384256905386308)]),\n",
       " (u'7@@ D@@',\n",
       "  [(u'36-@@ 7@@', 0.51869407415820701),\n",
       "   (u'10@@ 36-@@', 0.51869407415820701),\n",
       "   (u'4@@ 1-@@', 0.48369505324813),\n",
       "   (u'1-@@ 7@@', 0.42386383181610782),\n",
       "   (u'DB@@ 4', 0.37304642333742644),\n",
       "   (u'DD@@ 59@@', 0.37304642333742644),\n",
       "   (u'59@@ 1-@@', 0.37304642333742644),\n",
       "   (u'1-@@ 18@@', 0.37304642333742644),\n",
       "   (u'D@@ 70@@', 0.37142140048517192),\n",
       "   (u'3@@ DB@@', 0.37142140048517192),\n",
       "   (u'4@@ DD@@', 0.37142140048517192),\n",
       "   (u'7@@ 10@@', 0.37142140048517192),\n",
       "   (u'70@@ F@@', 0.36825517657553841),\n",
       "   (u'10@@ 7@@', 0.36825517657553841),\n",
       "   (u'2-@@ 10@@', 0.36403261038408558),\n",
       "   (u'10@@ 4@@', 0.36050892903337289),\n",
       "   (u'7@@ D@@', 0.35796153110841855),\n",
       "   (u'F@@ 3@@', 0.35388035280709945),\n",
       "   (u'1-@@ 10@@', 0.35386578999595392),\n",
       "   (u'64-@@ 000@@', 0.35072660017830098),\n",
       "   (u'32-@@ 000@@', 0.35072660017830098),\n",
       "   (u'18@@ 64-@@', 0.35072660017830098),\n",
       "   (u'18@@ 32-@@', 0.35072660017830098),\n",
       "   (u'F@@ 4@@', 0.34870651112868217),\n",
       "   (u'000@@ 1-@@', 0.34769758039021798),\n",
       "   (u'000@@ 2-@@', 0.34477125925369073),\n",
       "   (u'7@@ F@@', 0.33051161099464937)])]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pmi_cands.items()[:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
